package com.tjetc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tjetc.vo.Result;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.tjetc.mapper.HDepartmentMapper;
import com.tjetc.domain.HDepartment;
import com.tjetc.service.HDepartmentService;

import java.util.List;

@Service
public class HDepartmentServiceImpl implements HDepartmentService{

    @Resource
    private HDepartmentMapper hDepartmentMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return hDepartmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(HDepartment record) {
        return hDepartmentMapper.insert(record);
    }

    @Override
    public int insertSelective(HDepartment record) {
        return hDepartmentMapper.insertSelective(record);
    }

    @Override
    public HDepartment selectByPrimaryKey(Integer id) {
        return hDepartmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(HDepartment record) {
        return hDepartmentMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(HDepartment record) {
        return hDepartmentMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<HDepartment> selAll(String name, Integer curPage, Integer pageSize,Integer hid) {
        PageHelper.startPage(curPage,pageSize);
        if (hid == null){
            return new PageInfo<>(hDepartmentMapper.selAll(name));
        }else {
            return new PageInfo<>(hDepartmentMapper.selByHidAndName(name,hid));
        }
    }

    @Override
    public Integer delById(Integer id) {
        return hDepartmentMapper.delById(id);
    }

    @Override
    public Integer update(HDepartment hDepartment) {
        return hDepartmentMapper.updateByPrimaryKeySelective(hDepartment);
    }

    @Override
    public Integer add(HDepartment hDepartment) {
        return hDepartmentMapper.add(hDepartment);
    }

    @Override
    public Result selectByHid(Integer id) {
        List<HDepartment> hDepartments = hDepartmentMapper.selectByHidWithClinics(id);
        return Result.ok(hDepartments);
    }
}
